package com.uikoo9.manage.y.util;

import com.jfinal.plugin.activerecord.Model;
import com.uikoo9.util.core.annotation.QTable;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 15-5-31
 * Time: 下午11:36
 * To change this template use File | Settings | File Templates.
 */
public class JFQUtils {

    public static String getModelDbTable(Object o) {
        return ((Model) o).getClass().getAnnotation(QTable.class).value();
    }

    public static boolean checkSeeVideo(){
        Integer beforelunch = 1100;
        Integer afterlunch = 1330;
        Integer beforedinner = 1930;
        Integer afterdinner = 2100;
        Integer checktime = DateUtil.getIntMit();
        if(checktime<beforelunch || (beforedinner>checktime && checktime>afterlunch) || checktime>afterdinner){
            return false;
        }
        return  NumberTool.isPrime(DateUtil.getIntDate());
    }

    public static void main(String[] args) {
        String s = "\t事件：\t事件：\t事件：\t首先公司\t首先公司\t首先公司";
        s = s.replaceAll("(\\uF06E|\\uF0D8)*"," ");
        System.out.println(s);

        Calendar c = Calendar.getInstance();
        System.out.println("------check zs----------");
        List<Integer> li = new ArrayList<Integer>();
        for(int i=0;i<10;i++){
//            System.out.println();
//            getUniqueKey(c.getTime(),i);
            li.add(i);
        }
        Integer ii = new Integer(2);
        li.add(ii);
        System.out.println(li.indexOf(1)+"---"+li.indexOf(ii));
    }

    public static Integer getUniqueKey(Date date,Integer days){
        Calendar c = Calendar.getInstance();
        if(date != null){
            c.setTime(date);
        }
        if (days!= null){
            c.add(Calendar.DAY_OF_YEAR, days);
        }
        int j = 0;
        Integer lastprime = null;
        Date useday = c.getTime();
        for(int i=0 ;i<365;i++){
            c.add(Calendar.DAY_OF_YEAR, -1);
            Integer d =DateUtil.getIntDate(c.getTime(), "MMdd");
            if(NumberTool.isPrime(d)){
                j++;
                lastprime = d;
                System.out.println(i+j+"-"+d+"----------  ");
                break;
            }
        }
        Integer dd =DateUtil.getIntDate(useday, "dd");
        Integer yy =DateUtil.getIntDate(useday, "yyyy");
        Integer mm =DateUtil.getIntDate(useday, "MM");
        Integer re = (lastprime - lastprime/(dd+mm))* mm + yy +dd;
        System.out.println(DateUtil.getIntDate(useday, "yyyyMMdd")+"-"+lastprime+"-Unikey:"+re);
        return re;
    }

}
